package com.pactera.mavenweb.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.pactera.mavenweb.dao.GroupDao;
import com.pactera.mavenweb.entity.Group;
import com.pactera.mavenweb.service.GroupService;

@Service("groupService")
public class GroupServiceImp implements GroupService {
	
	/**
	 * 注入dao
	 */
	@Resource(name = "groupDao")
	private GroupDao groupDao;
	
//	@Override
	public int saveGroups(List<Group> groups) {
		try {
			for (Group group : groups) {
				groupDao.saveGroup(group);
			}
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
		return 0;
	}
	
//	@Override
	public List<Group> getAllGroup() {
		return groupDao.queryAll();
	}
	
//	@Override
	public void addGroup(Group group) {
		groupDao.saveGroup(group);
	}
	
//	@Override
	public boolean delGroup(String id) {
		
		groupDao.delete(id);
		
		return true;
	}
	
//	@Override
	public void updateGroup(Group group) {
		groupDao.update(group);
	}
	
//	@Override
	public Group getGroup(int id) {
		return groupDao.queryById(id);
	}
}